#include "projecttreeview.h"

ProjectTreeView::ProjectTreeView(QWidget *parent) :
    QTreeView(parent)
{
}

void ProjectTreeView::mouseReleaseEvent(QMouseEvent *event)
{
    if (event->button() == Qt::RightButton) {
        QModelIndex index = this->indexAt(event->pos());

        UmlGraphicsItem *item = static_cast<UmlGraphicsItem*>(index.internalPointer());

        if (!item) {
            QTreeView::mouseReleaseEvent(event);
        } else {
            QList<QAction*> contextMenu = item->contextActions();
            QMenu menu;
            menu.addActions(contextMenu);
            menu.exec(this->viewport()->mapToGlobal(event->pos()));
        }


    }

    QTreeView::mouseReleaseEvent(event);
}
